package com.mingqi.enetconnected.primary.mytask.activity;

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.mingqi.enetconnected.R;
import com.mingqi.enetconnected.base.BaseActivity;
import com.mingqi.enetconnected.primary.mytask.adapter.TaskNotificationAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class MessageDetailsActivity extends BaseActivity {

    @BindView(R.id.rv_message_details)
    RecyclerView mRvMessageDetails;
    @BindView(R.id.srl_message_details)
    SwipeRefreshLayout mSrlMessageDetails;
    @Override
    protected int getLayoutID() {
        return R.layout.activity_message_details;
    }

    @Override
    protected void initView() {

        String titleName = getIntent().getStringExtra("title");
        setTitleName(titleName);
    }

    @Override
    protected void initData() {

        List<String> strings = new ArrayList<>();
        for (int i = 0; i < 1; i++) {

            strings.add("");
        }
        final TaskNotificationAdapter adapter = new TaskNotificationAdapter(strings);
        mRvMessageDetails.setAdapter(adapter);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setStackFromEnd(false);//列表再底部开始展示，反转后由上面开始展示
//        linearLayoutManager.setReverseLayout(false);//列表翻转
        mRvMessageDetails.setLayoutManager(linearLayoutManager);

        mSrlMessageDetails.setColorSchemeColors(mContext.getResources().getColor(R.color.colorPrimary));
        mSrlMessageDetails.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {

                mSrlMessageDetails.postDelayed(new Runnable() {
                    @Override
                    public void run() {

                        adapter.addData(0,"");
                        adapter.addData(0,"");
                        adapter.addData(0,"");

                        mSrlMessageDetails.setRefreshing(false);
                    }
                },1000);
            }
        });
    }
}
